<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取方法的数组</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.getmethod.html">ReflectionClass::getMethod</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.getmodifiers.html">ReflectionClass::getModifiers</a></div>
 <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reflectionclass.getmethods" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::getMethods</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ReflectionClass::getMethods</span> &mdash; <span class="dc-title">获取方法的数组</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.getmethods-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>ReflectionClass::getMethods</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$filter</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   获取类的方法的一个数组。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.getmethods-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">filter</code></em></dt>

     <dd>

      <p class="para">
       过滤结果为仅包含某些属性的方法。默认不过滤。
      </p>
      <p class="para">
       <strong><code>ReflectionMethod::IS_STATIC</code></strong>、
       <strong><code>ReflectionMethod::IS_PUBLIC</code></strong>、
       <strong><code>ReflectionMethod::IS_PROTECTED</code></strong>、
       <strong><code>ReflectionMethod::IS_PRIVATE</code></strong>、
       <strong><code>ReflectionMethod::IS_ABSTRACT</code></strong>、
       <strong><code>ReflectionMethod::IS_FINAL</code></strong> 的任意组合。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.getmethods-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   包含每个方法 <a href="class.reflectionmethod.html" class="classname">ReflectionMethod</a> 对象的<span class="type"><span class="type 数组">数组</span></span>。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-reflectionclass.getmethods-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5094">
    <p><strong>Example #1 <span class="methodname"><strong>ReflectionClass::getMethods()</strong></span> 的基本用法</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Apple&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">firstMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;final&nbsp;protected&nbsp;function&nbsp;</span><span style="color: #0000BB">secondMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">thirdMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$class&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Apple'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$methods&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMethods</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$methods</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(3) {
  [0]=&gt;
  &amp;object(ReflectionMethod)#2 (2) {
    [&quot;name&quot;]=&gt;
    string(11) &quot;firstMethod&quot;
    [&quot;class&quot;]=&gt;
    string(5) &quot;Apple&quot;
  }
  [1]=&gt;
  &amp;object(ReflectionMethod)#3 (2) {
    [&quot;name&quot;]=&gt;
    string(12) &quot;secondMethod&quot;
    [&quot;class&quot;]=&gt;
    string(5) &quot;Apple&quot;
  }
  [2]=&gt;
  &amp;object(ReflectionMethod)#4 (2) {
    [&quot;name&quot;]=&gt;
    string(11) &quot;thirdMethod&quot;
    [&quot;class&quot;]=&gt;
    string(5) &quot;Apple&quot;
  }
}
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-5095">
    <p><strong>Example #2 从 <span class="methodname"><strong>ReflectionClass::getMethods()</strong></span> 中过滤结果</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">Apple&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">firstMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;final&nbsp;protected&nbsp;function&nbsp;</span><span style="color: #0000BB">secondMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000BB">thirdMethod</span><span style="color: #007700">()&nbsp;{&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$class&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">'Apple'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$methods&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMethods</span><span style="color: #007700">(</span><span style="color: #0000BB">ReflectionMethod</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_STATIC&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">ReflectionMethod</span><span style="color: #007700">::</span><span style="color: #0000BB">IS_FINAL</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$methods</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(2) {
  [0]=&gt;
  &amp;object(ReflectionMethod)#2 (2) {
    [&quot;name&quot;]=&gt;
    string(12) &quot;secondMethod&quot;
    [&quot;class&quot;]=&gt;
    string(5) &quot;Apple&quot;
  }
  [1]=&gt;
  &amp;object(ReflectionMethod)#3 (2) {
    [&quot;name&quot;]=&gt;
    string(11) &quot;thirdMethod&quot;
    [&quot;class&quot;]=&gt;
    string(5) &quot;Apple&quot;
  }
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.getmethods-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionclass.getmethod.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::getMethod()</a> - 获取一个类方法的 ReflectionMethod。</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.getmethod.html">ReflectionClass::getMethod</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.getmodifiers.html">ReflectionClass::getModifiers</a></div>
 <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
